/*
 * @(#)DualLinkedBidiMap.java $version 2011. 10. 14
 * 
 * Copyright 2011 NHN Corp. All rights Reserved.
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.hangame.mbl.util;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Map;

import org.apache.commons.collections.BidiMap;
import org.apache.commons.collections.bidimap.AbstractDualBidiMap;
import org.apache.commons.collections.map.LinkedMap;

// TODO: Auto-generated Javadoc
/**
 * The Class DualLinkedBidiMap.
 * 
 * @author KR14386
 */
@SuppressWarnings({"serial", "rawtypes"})
public class DualLinkedBidiMap extends AbstractDualBidiMap implements Serializable {

	/**
	 * Instantiates a new dual linked bidi map.
	 */
	public DualLinkedBidiMap() {
		super(new LinkedMap(), new LinkedMap());
	}

	/**
	 * Instantiates a new dual linked bidi map.
	 * 
	 * @param map the map
	 */
	public DualLinkedBidiMap(Map map) {
		super(new LinkedMap(), new LinkedMap());
		putAll(map);
	}

	/**
	 * Instantiates a new dual linked bidi map.
	 * 
	 * @param normalMap the normal map
	 * @param reverseMap the reverse map
	 * @param inverseBidiMap the inverse bidi map
	 */
	protected DualLinkedBidiMap(Map normalMap, Map reverseMap, BidiMap inverseBidiMap) {
		super(normalMap, reverseMap, inverseBidiMap);
	}
	
	/**
	 * Creates the bidi map.
	 * 
	 * @param normalMap Map
	 * @param reverseMap Map
	 * @param inverseBidiMap BidiMap
	 * @return BidiMap
	 * @see org.apache.commons.collections.bidimap.AbstractDualBidiMap#createBidiMap(java.util.Map, java.util.Map, org.apache.commons.collections.BidiMap)
	 */
	protected BidiMap createBidiMap(Map normalMap, Map reverseMap, BidiMap inverseBidiMap) {
		return new DualLinkedBidiMap(normalMap, reverseMap, inverseBidiMap);
	}

	/**
	 * Write object.
	 * 
	 * @param out ObjectOutputStream
	 * @throws IOException IOException
	 */ 
	private void writeObject(ObjectOutputStream out) throws IOException {
		out.defaultWriteObject();
		out.writeObject(maps[0]);
	}

	/**
	 * Read object.
	 * 
	 * @param in ObjectInputStream
	 * @throws IOException IOException
	 * @throws ClassNotFoundException ClassNotFoundException
	 */
	private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
		in.defaultReadObject();
		maps[0] = new LinkedMap();
		maps[1] = new LinkedMap();
		Map map = (Map)in.readObject();
		putAll(map);
	}
}
